
// EDGE
import {Edge as BaseEdge, Graph} from "@antv/x6";

Graph.registerEdge(
  'common-edge',
  {
    inherit: 'edge',
    attrs: {
      line: {
        stroke: '#C7CDDB',
        strokeWidth: 2,
        targetMarker: {
          name: 'block',
          width: 10,
          height: 10,
        },
      },
    },
  },
  true,
)

Graph.registerEdge(
  'condition-edge',
  {
    inherit: 'common-edge',
    defaultLabel: {
      markup: [
        {
          tagName: 'rect',
          selector: 'body',
        },
        {
          tagName: 'text',
          selector: 'label',
        },
      ],
      attrs: {
        label: {
          fill: '#000',
          fontSize: 14,
          textAnchor: 'middle',
          textVerticalAnchor: 'middle',
          pointerEvents: 'none',
        },
        body: {
          ref: 'label',
          fill: 'white',
          stroke: '#B9C1FF',
          strokeWidth: 1,
          strokeDasharray: '5,5',
          rx: 4,
          ry: 4,
          refWidth: '140%',
          refHeight: '140%',
          refX: '-20%',
          refY: '-20%',
        },
      },
      position: {
        distance: 20,
        options: {
          // absoluteDistance: true,
          // reverseDistance: true,
        },
      },
    }
  },
  true,
)

Graph.registerEdge(
  'switcherConcurrent-edge',
  {
    inherit: 'common-edge',
  },
  true,
)


Graph.registerEdge(
  'switcherCondition-edge',
  {
    inherit: 'common-edge',
    attrs: {
      line: {
        stroke: '#C7CDDB',
        strokeDasharray: 5,
        targetMarker: 'classic',
      },
    },
    defaultLabel: {
      markup: [
        {
          tagName: 'rect',
          selector: 'body',
        },
        {
          tagName: 'text',
          selector: 'label',
        },
      ],
      attrs: {
        label: {
          fill: '#000',
          fontSize: 14,
          textAnchor: 'middle',
          textVerticalAnchor: 'middle',
          pointerEvents: 'none',
        },
        body: {
          ref: 'label',
          fill: 'white',
          stroke: '#B9C1FF',
          strokeWidth: 1,
          strokeDasharray: '5,5',
          rx: 4,
          ry: 4,
          refWidth: '140%',
          refHeight: '140%',
          refX: '-20%',
          refY: '-20%',
        },
      },
      position: {
        distance: -20,
        options: {
          absoluteDistance: true,
          reverseDistance: true,
        },
      },
    }
  },
  true,
)

Graph.registerEdge(
  'abtest-edge',
  {
    inherit: 'common-edge',
    defaultLabel: {
      markup: [
        {
          tagName: 'rect',
          selector: 'body',
        },
        {
          tagName: 'text',
          selector: 'label',
        },
      ],
      attrs: {
        label: {
          fill: '#2C313B',
          fontSize: 14,
          textAnchor: 'middle',
          textVerticalAnchor: 'middle',
          pointerEvents: 'none',
        },
        body: {
          ref: 'label',
          fill: 'white',
          stroke: '#B9C1FF',
          strokeWidth: 1,
          strokeDasharray: '5,5',
          rx: 4,
          ry: 4,
          refWidth: '140%',
          refHeight: '140%',
          refX: '-20%',
          refY: '-20%',
        },
      },
      position: {
        distance: -21,
      },
    },
  },
)
